package cn.csg.iotplatform.module.system.dal.mysql.userdept;

import java.util.*;

import cn.csg.iotplatform.framework.common.pojo.PageResult;
import cn.csg.iotplatform.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.csg.iotplatform.framework.mybatis.core.mapper.BaseMapperX;
import cn.csg.iotplatform.module.system.dal.dataobject.userdept.UserDeptDO;
import org.apache.ibatis.annotations.Mapper;
import cn.csg.iotplatform.module.system.controller.admin.userdept.vo.*;
import org.apache.ibatis.annotations.Param;

/**
 * 用户设备单位授权 Mapper
 *
 * @author 系统管理员
 */
@Mapper
public interface UserDeptMapper extends BaseMapperX<UserDeptDO> {

    default PageResult<UserDeptDO> selectPage(UserDeptPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<UserDeptDO>()
                .eqIfPresent(UserDeptDO::getUserId, reqVO.getUserId())
                .eqIfPresent(UserDeptDO::getDeptId, reqVO.getDeptId())
                .betweenIfPresent(UserDeptDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(UserDeptDO::getId));
    }

    List<UserDeptDO> getAuthDeptIds(@Param("userId") Long userId);

    List<Long> selectAutoAuthUserIds(@Param("deptId") Long deptId);

}